home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
ndr3.exe
/
VOLSTAT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-31
|
6KB
|
222 lines
//
// VolStat - Lists all Volume Information for each volume on the
// current server; distinguishes between Netware OS
// versions and makes the appropriate (2x or 3x) call
//
// by Charles Rose. Copyright (c) 1993, RoseWare. All Rights Reserved
//
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef unsigned long DWORD;
/* Reply structure */
struct tag3XInfo {
DWORD TotalBlocks;
DWORD FreeBlocks;
DWORD PurgableBlocks;
DWORD NotYetPurgableBlocks;
DWORD TotalDirectoryEntries;
DWORD AvailableDirectoryEntries;
DWORD reserved;
BYTE SectorsPerBlock;
BYTE VolumeNameLength;
BYTE VolumeName[48];
} VolInfo3X;
struct tag2XInfo {
WORD Length;
DWORD ElapsedTime;
BYTE VolumeNumber;
BYTE LogicalDriveNumber;
WORD SectorsPerBlock;
WORD StartingBlock;
WORD TotalBlocks;
WORD AvailableBlocks;
WORD TotalDirSlots;
WORD AvailableDirSlots;
WORD ActualMaxUsedDirSlots;
BYTE IsHashed;
BYTE IsCached;
BYTE IsRemovable;
BYTE IsMounted;
BYTE VolumeName[16];
} VolInfo2X;
int Get3XVolumeInformation( BYTE volume );
void Print3XResults( int x );
int Get2XVolumeInformation( BYTE volume );
void Print2XResults( void );
WORD WordSwap( BYTE *before );
char Is3XSupported( void );
void main();
void main()
{
int x, result;
printf("VOLSTAT Copyright (c) 1993, RoseWare. All Rights Reserved\n\n");
// Check if NetWare 3.x (and above) is supported. If so, make F2h
// function call, otherwise, use standard 2.x E3h call. Print
// results based on type of call made.
if ( Is3XSupported() )
{
for ( x = 0; x < 32; x++ )
{
result = Get3XVolumeInformation( x );
if ( !VolInfo3X.TotalBlocks ) exit( 1 );
else if ( result )
{
printf( "Err: Get3XVolInfo, Vol %d, code %X\n",
x, result );
exit(1);
}
Print3XResults( x );
}
}
else
{
for ( x = 0; x < 32; x++ )
{
result = Get2XVolumeInformation( x );
if ( result == 0x98 ) exit( 1 );
else if ( result )
{
printf( "Err: Get2XVolInfo, Vol %d, code %X\n",
x, result );
exit(1);
}
Print2XResults();
}
}
}
int Get3XVolumeInformation( BYTE volume )
{
BYTE Request[4] = { 2, 0, 0x2C, 0 };
Request[3] = volume;
_CX = 4;
_DX = sizeof( struct tag3XInfo );
_SI = (unsigned)Request;
_DI = (unsigned)&VolInfo3X;
// This line needs to preceed any code that manipulates the AX
// register, since it generates the code:
// mov ax, ds
// mov ds, ax
// which clobbers your AX register. Placing any AX-modifying
// code after this line, though, is ok.
_ES = _DS;
_AX = 0xF216;
geninterrupt( 0x21 );
return _AL;
}
int Get2XVolumeInformation( BYTE volume )
{
BYTE Request[4] = { 2, 0, 0xE9, 0 };
Request[3] = volume;
VolInfo2X.Length = sizeof( struct tag2XInfo ) - 2;
_SI = (unsigned)Request;
_DI = (unsigned)&VolInfo2X;
_ES = _DS;
_AH = 0xE3;
geninterrupt( 0x21 );
return _AL;
}
void Print3XResults( int x )
{
printf( "Volume #%d [%s]\n", x, VolInfo3X.VolumeName );
printf( "-Storage Space-\n" );
printf( " Total Blocks : %10lu Total Megabytes : %10lu\n ",
VolInfo3X.TotalBlocks, ( VolInfo3X.TotalBlocks *
(DWORD)VolInfo3X.SectorsPerBlock*(DWORD)512)/((DWORD)1024*(DWORD)1024));
printf( " Blocks Left : %10lu Megabytes Left : %10lu\n ", VolInfo3X.FreeBlocks,
( VolInfo3X.FreeBlocks * (DWORD)VolInfo3X.SectorsPerBlock * (DWORD)512 ) / ( (DWORD)1024 * (DWORD)1024) );
printf( " Purgable Blocks : %10lu Purgable Megs : %10lu\n ", VolInfo3X.PurgableBlocks,
( VolInfo3X.PurgableBlocks * (DWORD)VolInfo3X.SectorsPerBlock * (DWORD)512 ) / ( (DWORD)1024 * (DWORD)1024) );
printf( "-Directories-\n" );
printf( " Total Entries : %10lu Entries Left : %10lu\n", VolInfo3X.TotalDirectoryEntries,
VolInfo3X.AvailableDirectoryEntries );
printf( "\n" );
}
void Print2XResults( void )
{
printf( "Volume #%d [%s]\n", (WORD)VolInfo2X.VolumeNumber, VolInfo2X.VolumeName );
if ( VolInfo2X.IsHashed ) printf( "Hashed " ); else printf( "NOT Hashed " );
if ( VolInfo2X.IsCached ) printf( "Cached " ); else printf( "NOT Cached " );
if ( VolInfo2X.IsRemovable ) printf( "Removable " ); else printf( "Fixed " );
if ( VolInfo2X.IsMounted ) printf( "Mounted " ); else printf( "NOT MOUNTED " );
printf( "\n" );
printf( "-Storage Space-\n" );
printf( " Total Blocks : %10d Total Megabytes : %10lu\n ", WordSwap( (BYTE *)&VolInfo2X.TotalBlocks ),
( (DWORD)WordSwap( (BYTE *)&VolInfo2X.TotalBlocks ) *
(DWORD)WordSwap( (BYTE *)&VolInfo2X.SectorsPerBlock ) *
(DWORD)512 ) / ((DWORD)1024*(DWORD)1024) );
printf( " Blocks Left : %10d Megabytes Left : %10lu\n ", WordSwap( (BYTE *)&VolInfo2X.AvailableBlocks ),
( (DWORD)WordSwap( (BYTE *)&VolInfo2X.AvailableBlocks ) *
(DWORD)WordSwap( (BYTE *)&VolInfo2X.SectorsPerBlock ) *
(DWORD)512 ) / ((DWORD)1024*(DWORD)1024) );
printf( "-Directories-\n" );
printf( " Total Slots : %10d Slots Left : %10d\n", WordSwap( (BYTE *)&VolInfo2X.TotalDirSlots ),
WordSwap( (BYTE *)&VolInfo2X.AvailableDirSlots ) );
printf( "\n" );
}
char Is3XSupported( void )
{
char reply[130], retVal;
BYTE request[3] = { 1, 0, 0x11 };
*((WORD *)reply) = 128;
_SI = (unsigned)request;
_DI = (unsigned)reply;
_ES = _DS;
_AH = 0xE3;
geninterrupt( 0x21 );
retVal = _AL;
if ( retVal )
{
printf("Error calling Get File Server Information, ret code = %X\n",
retVal );
exit( 1 );
}
if ( reply[50] >= 3 )
return 1;
else
return 0;
}
WORD WordSwap( BYTE *before )
{
BYTE after[2];
after[0] = before[1];
after[1] = before[0];
return *( (WORD *) after );
}